package com.abhinav.designPatterns;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import com.abhinav.designPatterns.singleton.SingletonClass;
import com.abhinav.designPatterns.singleton.SingletonEnum;

public class Main {

	public static void main(String[] args) {
		/*SingletonClass obj1, obj2;

		obj1 = SingletonClass.getInstance();

		System.out.println(obj1);
		// obj = obj.clone();

		System.out.println("Serializing SingletonClass: ");
		try {
			FileOutputStream fileOut = new FileOutputStream("employee.ser");
			ObjectOutputStream out = new ObjectOutputStream(fileOut);
			out.writeObject(obj1);
			out.close();
			fileOut.close();
		} catch (IOException i) {
			i.printStackTrace();
		}

		System.out.println("De-serializing SingletonClass: ");

		try {
			FileInputStream fileIn = new FileInputStream("employee.ser");
			ObjectInputStream in = new ObjectInputStream(fileIn);
			obj2 = (SingletonClass) in.readObject();
			if (obj2 == null) {
				System.out.println("Object null");
			}
			in.close();
			fileIn.close();
		} catch (IOException i) {
			i.printStackTrace();
			return;
		} catch (ClassNotFoundException c) {
			System.out.println("SingletonClass class not found");
			c.printStackTrace();
			return;
		}

		System.out.println("Deserialized SingletonClass...");
		System.out.println("obj: " + obj2);*/

		// System.out.println(obj1.equals(obj2));
		// System.out.println(obj1 == obj2);

		SingletonEnum obj11, obj22;
		
		obj11 = SingletonEnum.INSTANCE;
		
		System.out.println(obj11.getI());
		
		obj22 = SingletonEnum.INSTANCE;
		
		System.out.println(obj22.getI());
	}

}
